{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports\n",
    "\n",
    "Import all the modules and functionalities we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "# Import standard libraries.\n",
    "import os\n",
    "\n",
    "# Import third party libraries.\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from statsmodels.stats.multitest import multipletests\n",
    "from statsmodels.stats.proportion import proportions_ztest\n",
    "\n",
    "# Import custom libraries/scripts.\n",
    "import annotations\n",
    "import helpers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading data\n",
    "\n",
    "Fetch all our relevant data for the current analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set working contants.\n",
    "EXPERIMENTS_PATH = r'\\\\10.40.12.80\\home\\PhD\\Results\\Competition\\DL\\small_arenas\\two_females_only\\processed'\n",
    "FPS = 60\n",
    "N_MINUTES = 55\n",
    "N_FRAMES = N_MINUTES * 60 * FPS\n",
    "INK = 'black'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set figure configurations.\n",
    "sns.set(\n",
    "        context='paper',\n",
    "        style='ticks',\n",
    "        font='sans-serif',\n",
    "        font_scale=1.0, \n",
    "        rc={\n",
    "            'axes.axisbelow': True,\n",
    "            'axes.edgecolor': INK,\n",
    "            'axes.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'axes.grid': False,\n",
    "            'axes.labelcolor': INK,\n",
    "            'axes.labelsize': 13.0,\n",
    "            'axes.labelweight': 'normal',\n",
    "            'axes.linewidth': 1.0,\n",
    "            'axes.spines.left': True,\n",
    "            'axes.spines.bottom': True,\n",
    "            'axes.spines.top': False,\n",
    "            'axes.spines.right': False,\n",
    "            'axes.titlepad': 15.0,\n",
    "            'axes.titlesize': 20.0,\n",
    "            'axes.titleweight': 'bold',\n",
    "            'figure.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'figure.figsize': [4.0, 4.0],\n",
    "            'figure.titlesize': 30.0,\n",
    "            'figure.titleweight': 'bold',\n",
    "            'font.family': ['sans-serif'],\n",
    "            'font.sans-serif': ['Arial'],\n",
    "            'legend.frameon': False,\n",
    "            'legend.fontsize': 11.0,\n",
    "            'lines.color': INK,\n",
    "            'lines.linewidth': 1.0,\n",
    "            'patch.edgecolor': INK,\n",
    "            'savefig.dpi': 300,\n",
    "            'savefig.format': 'png',\n",
    "            'savefig.bbox': 'tight',\n",
    "            'savefig.transparent': True,\n",
    "            'text.color': INK,\n",
    "            'text.usetex': False,\n",
    "            'xtick.color': INK,\n",
    "            'xtick.direction': 'out',\n",
    "            'xtick.labelsize': 12.0,\n",
    "            'xtick.major.pad': 5.0,\n",
    "            'xtick.major.size': 0.0,\n",
    "            'xtick.major.width': 1.0,\n",
    "            'xtick.minor.size': 0.0,\n",
    "            'xtick.minor.width': 0.4,\n",
    "            'ytick.color': INK,\n",
    "            'ytick.direction': 'out',\n",
    "            'ytick.labelsize': 12.0,\n",
    "            'ytick.major.pad': 5.0,\n",
    "            'ytick.major.size': 3.0,\n",
    "            'ytick.major.width': 1.0,\n",
    "            'ytick.minor.size': 0.0,\n",
    "            'ytick.minor.width': 0.4\n",
    "           }\n",
    "       )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder already exists, skipping.\n"
     ]
    }
   ],
   "source": [
    "# Prepare the Figures folder to save our graphs in.\n",
    "savepath = os.path.join(r'C:\\Users\\Miguel\\Desktop\\paper_data', 'paper_figures', 'figureS3')\n",
    "try:\n",
    "    os.makedirs(savepath)\n",
    "    print('New folder created.')\n",
    "except FileExistsError:\n",
    "    print('Folder already exists, skipping.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paths to conditions:\n",
      " ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food', '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food']\n"
     ]
    }
   ],
   "source": [
    "# Set the conditions to analyze.\n",
    "condition_order = ['food', 'no_food']\n",
    "conditions = [item.path for item in os.scandir(EXPERIMENTS_PATH) if item.name in condition_order]\n",
    "print('Paths to conditions:\\n', conditions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'food': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T10_41_16_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T11_37_33_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T11_37_33_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T11_37_33_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T11_37_33_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T11_37_33_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T11_37_33_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-12T11_37_33_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_01_30_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T10_57_35_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\food\\\\video_2019-12-18T11_55_14_arena9.csv'],\n",
       " 'no_food': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T10_41_16_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-12T11_37_33_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_01_30_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T10_57_35_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\two_females_only\\\\processed\\\\no_food\\\\video_2019-12-18T11_55_14_arena8.csv']}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load all usable experiments for each condition.\n",
    "experiments = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition_path in conditions:\n",
    "    for item in os.scandir(condition_path):\n",
    "        \n",
    "        experiments[os.path.basename(condition_path)].append(item.path)\n",
    "\n",
    "experiments"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Aggression Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 0 \n",
      "Experiment: video_2019-12-12T10_41_16_arena11.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2019-12-12T10_41_16_arena12.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2019-12-12T10_41_16_arena15.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2019-12-12T10_41_16_arena16.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2019-12-12T10_41_16_arena3.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2019-12-12T10_41_16_arena4.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2019-12-12T10_41_16_arena7.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2019-12-12T10_41_16_arena8.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2019-12-12T11_37_33_arena10.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2019-12-12T11_37_33_arena13.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2019-12-12T11_37_33_arena14.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2019-12-12T11_37_33_arena2.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2019-12-12T11_37_33_arena5.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2019-12-12T11_37_33_arena6.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2019-12-12T11_37_33_arena9.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2019-12-18T10_01_30_arena10.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2019-12-18T10_01_30_arena11.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2019-12-18T10_01_30_arena12.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2019-12-18T10_01_30_arena13.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2019-12-18T10_01_30_arena14.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2019-12-18T10_01_30_arena15.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2019-12-18T10_01_30_arena16.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2019-12-18T10_01_30_arena9.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2019-12-18T10_57_35_arena1.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2019-12-18T10_57_35_arena2.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2019-12-18T10_57_35_arena3.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2019-12-18T10_57_35_arena4.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2019-12-18T10_57_35_arena5.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2019-12-18T10_57_35_arena6.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2019-12-18T10_57_35_arena7.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2019-12-18T10_57_35_arena8.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2019-12-18T11_55_14_arena1.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 32 \n",
      "Experiment: video_2019-12-18T11_55_14_arena10.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 33 \n",
      "Experiment: video_2019-12-18T11_55_14_arena13.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 34 \n",
      "Experiment: video_2019-12-18T11_55_14_arena14.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 35 \n",
      "Experiment: video_2019-12-18T11_55_14_arena2.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 36 \n",
      "Experiment: video_2019-12-18T11_55_14_arena5.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 37 \n",
      "Experiment: video_2019-12-18T11_55_14_arena6.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 38 \n",
      "Experiment: video_2019-12-18T11_55_14_arena9.csv \n",
      "Condition: food \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2019-12-12T10_41_16_arena1.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2019-12-12T10_41_16_arena10.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2019-12-12T10_41_16_arena13.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2019-12-12T10_41_16_arena14.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2019-12-12T10_41_16_arena2.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2019-12-12T10_41_16_arena5.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2019-12-12T10_41_16_arena6.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2019-12-12T10_41_16_arena9.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2019-12-12T11_37_33_arena11.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2019-12-12T11_37_33_arena12.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2019-12-12T11_37_33_arena15.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2019-12-12T11_37_33_arena16.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2019-12-12T11_37_33_arena3.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2019-12-12T11_37_33_arena4.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2019-12-12T11_37_33_arena7.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2019-12-12T11_37_33_arena8.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2019-12-18T10_01_30_arena1.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2019-12-18T10_01_30_arena2.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2019-12-18T10_01_30_arena3.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2019-12-18T10_01_30_arena4.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2019-12-18T10_01_30_arena5.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2019-12-18T10_01_30_arena6.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2019-12-18T10_01_30_arena7.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2019-12-18T10_01_30_arena8.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2019-12-18T10_57_35_arena10.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2019-12-18T10_57_35_arena11.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2019-12-18T10_57_35_arena12.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2019-12-18T10_57_35_arena13.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2019-12-18T10_57_35_arena14.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2019-12-18T10_57_35_arena15.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2019-12-18T10_57_35_arena16.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2019-12-18T10_57_35_arena9.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 32 \n",
      "Experiment: video_2019-12-18T11_55_14_arena11.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 33 \n",
      "Experiment: video_2019-12-18T11_55_14_arena12.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 34 \n",
      "Experiment: video_2019-12-18T11_55_14_arena15.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 35 \n",
      "Experiment: video_2019-12-18T11_55_14_arena16.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 36 \n",
      "Experiment: video_2019-12-18T11_55_14_arena3.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 37 \n",
      "Experiment: video_2019-12-18T11_55_14_arena4.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 38 \n",
      "Experiment: video_2019-12-18T11_55_14_arena7.csv \n",
      "Condition: no_food \n",
      "\n",
      "Iteration: 39 \n",
      "Experiment: video_2019-12-18T11_55_14_arena8.csv \n",
      "Condition: no_food \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>has_food</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>27</td>\n",
       "      <td>7</td>\n",
       "      <td>0.001500</td>\n",
       "      <td>1.4</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena11.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>38</td>\n",
       "      <td>2</td>\n",
       "      <td>0.002111</td>\n",
       "      <td>0.4</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena12.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>15</td>\n",
       "      <td>5</td>\n",
       "      <td>0.000833</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena15.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000167</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>0.000333</td>\n",
       "      <td>0.4</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena4.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>41</td>\n",
       "      <td>3</td>\n",
       "      <td>0.002278</td>\n",
       "      <td>0.6</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena7.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>43</td>\n",
       "      <td>9</td>\n",
       "      <td>0.002389</td>\n",
       "      <td>1.8</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena8.csv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>79 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  has_food  nframes  nbouts  ratio_frames  ratio_bouts  \\\n",
       "0             True      True       27       7      0.001500          1.4   \n",
       "1             True      True       38       2      0.002111          0.4   \n",
       "2             True      True       15       5      0.000833          1.0   \n",
       "3             True      True        3       1      0.000167          0.2   \n",
       "4            False      True        0       0      0.000000          0.0   \n",
       "..             ...       ...      ...     ...           ...          ...   \n",
       "74           False     False        0       0      0.000000          0.0   \n",
       "75            True     False        6       2      0.000333          0.4   \n",
       "76           False     False        0       0      0.000000          0.0   \n",
       "77            True     False       41       3      0.002278          0.6   \n",
       "78            True     False       43       9      0.002389          1.8   \n",
       "\n",
       "   condition                             experiment  \n",
       "0       food  video_2019-12-12T10_41_16_arena11.csv  \n",
       "1       food  video_2019-12-12T10_41_16_arena12.csv  \n",
       "2       food  video_2019-12-12T10_41_16_arena15.csv  \n",
       "3       food  video_2019-12-12T10_41_16_arena16.csv  \n",
       "4       food   video_2019-12-12T10_41_16_arena3.csv  \n",
       "..       ...                                    ...  \n",
       "74   no_food  video_2019-12-18T11_55_14_arena16.csv  \n",
       "75   no_food   video_2019-12-18T11_55_14_arena3.csv  \n",
       "76   no_food   video_2019-12-18T11_55_14_arena4.csv  \n",
       "77   no_food   video_2019-12-18T11_55_14_arena7.csv  \n",
       "78   no_food   video_2019-12-18T11_55_14_arena8.csv  \n",
       "\n",
       "[79 rows x 8 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aggression_df = pd.DataFrame()\n",
    "for condition in condition_order:\n",
    "    for h, experiment_path in enumerate(experiments[condition]):\n",
    "\n",
    "        experiment = os.path.basename(experiment_path)\n",
    "        \n",
    "        print('Iteration:', h, '\\nExperiment:', experiment, '\\nCondition:', condition, '\\n')\n",
    "        \n",
    "        annotation_video = annotations.read(experiment_path)\n",
    "        \n",
    "        # Get aggression only from minute 5 to minute 10.\n",
    "        aggression_events = []\n",
    "        for event in annotation_video[1].events:\n",
    "            if (event.time >= (5 * 60 * FPS) and event.time < (10 * 60 * FPS)):\n",
    "                aggression_events.append(event)\n",
    "\n",
    "        n_events = len(aggression_events)\n",
    "\n",
    "        # In case there is aggression, do the necessary calculations.\n",
    "        if n_events > 0:\n",
    "            ratio_frames = sum([aggression.duration for aggression in aggression_events]) / (5 * 60 * FPS) # Although the movies are 55 minutes long, we only annotated the first 15 minutes of each video.\n",
    "            ratio_bouts = n_events / 5\n",
    "\n",
    "            aggression_data = pd.DataFrame({'has_aggression': True,\n",
    "                                            'has_food': True if condition == 'food' else False,\n",
    "                                            'nframes': sum([aggression.duration for aggression in aggression_events]),\n",
    "                                            'nbouts': n_events,\n",
    "                                            'ratio_frames': ratio_frames,\n",
    "                                            'ratio_bouts': ratio_bouts,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # If not, preset our dictionary with default values.\n",
    "        else:\n",
    "            aggression_data = pd.DataFrame({'has_aggression': False,\n",
    "                                            'has_food': True if condition == 'food' else False,\n",
    "                                            'nframes': 0,\n",
    "                                            'nbouts': 0,\n",
    "                                            'ratio_frames': 0, \n",
    "                                            'ratio_bouts': 0,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # Concatenate all data together.\n",
    "        aggression_df = pd.concat([aggression_df, aggression_data], ignore_index=True)\n",
    "\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Outlier Detection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t food \n",
      "\n",
      "[10]\n",
      "Number data points considered outliers: 1\n",
      "Percent data points considered outliers: 2.564 %\n",
      "\n",
      "\t no_food \n",
      "\n",
      "[51]\n",
      "Number data points considered outliers: 1\n",
      "Percent data points considered outliers: 2.5 %\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>has_food</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>27</td>\n",
       "      <td>7</td>\n",
       "      <td>0.001500</td>\n",
       "      <td>1.4</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena11.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>38</td>\n",
       "      <td>2</td>\n",
       "      <td>0.002111</td>\n",
       "      <td>0.4</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena12.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>15</td>\n",
       "      <td>5</td>\n",
       "      <td>0.000833</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena15.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000167</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>food</td>\n",
       "      <td>video_2019-12-12T10_41_16_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>0.000333</td>\n",
       "      <td>0.4</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena4.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>41</td>\n",
       "      <td>3</td>\n",
       "      <td>0.002278</td>\n",
       "      <td>0.6</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena7.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>43</td>\n",
       "      <td>9</td>\n",
       "      <td>0.002389</td>\n",
       "      <td>1.8</td>\n",
       "      <td>no_food</td>\n",
       "      <td>video_2019-12-18T11_55_14_arena8.csv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>77 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  has_food  nframes  nbouts  ratio_frames  ratio_bouts  \\\n",
       "0             True      True       27       7      0.001500          1.4   \n",
       "1             True      True       38       2      0.002111          0.4   \n",
       "2             True      True       15       5      0.000833          1.0   \n",
       "3             True      True        3       1      0.000167          0.2   \n",
       "4            False      True        0       0      0.000000          0.0   \n",
       "..             ...       ...      ...     ...           ...          ...   \n",
       "74           False     False        0       0      0.000000          0.0   \n",
       "75            True     False        6       2      0.000333          0.4   \n",
       "76           False     False        0       0      0.000000          0.0   \n",
       "77            True     False       41       3      0.002278          0.6   \n",
       "78            True     False       43       9      0.002389          1.8   \n",
       "\n",
       "   condition                             experiment  \n",
       "0       food  video_2019-12-12T10_41_16_arena11.csv  \n",
       "1       food  video_2019-12-12T10_41_16_arena12.csv  \n",
       "2       food  video_2019-12-12T10_41_16_arena15.csv  \n",
       "3       food  video_2019-12-12T10_41_16_arena16.csv  \n",
       "4       food   video_2019-12-12T10_41_16_arena3.csv  \n",
       "..       ...                                    ...  \n",
       "74   no_food  video_2019-12-18T11_55_14_arena16.csv  \n",
       "75   no_food   video_2019-12-18T11_55_14_arena3.csv  \n",
       "76   no_food   video_2019-12-18T11_55_14_arena4.csv  \n",
       "77   no_food   video_2019-12-18T11_55_14_arena7.csv  \n",
       "78   no_food   video_2019-12-18T11_55_14_arena8.csv  \n",
       "\n",
       "[77 rows x 8 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corrected_ratio_frames = pd.DataFrame()\n",
    "\n",
    "for condition in condition_order:\n",
    "\n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        dataset = aggression_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "        outlier_positions = helpers.check_outliers(dataset)\n",
    "        print(outlier_positions)\n",
    "\n",
    "        fresh_dataset = pd.DataFrame(helpers.remove_outliers(dataset, indices=outlier_positions))\n",
    "        fresh_dataset['condition'] = condition\n",
    "\n",
    "        corrected_ratio_frames = pd.concat([corrected_ratio_frames, fresh_dataset], axis=0)\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "\n",
    "aggression_df = aggression_df.loc[corrected_ratio_frames.index]\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Aggression Bouts / Min."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>has_food</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.4</td>\n",
       "      <td>food</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.4</td>\n",
       "      <td>food</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0</td>\n",
       "      <td>food</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.2</td>\n",
       "      <td>food</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.0</td>\n",
       "      <td>food</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ratio_bouts condition  has_food\n",
       "0          1.4      food      True\n",
       "1          0.4      food      True\n",
       "2          1.0      food      True\n",
       "3          0.2      food      True\n",
       "4          0.0      food      True"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_df = aggression_df.copy()[['ratio_bouts', 'condition', 'has_food']]\n",
    "ratio_bouts_df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t no_food \n",
      "\n",
      "Shapiro's Test: group 1 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 1 IS NOT normally distributed.\n",
      "Shapiro's Test: group 2 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 2 IS NOT normally distributed.\n",
      "Levene's Test for non-normally distributed samples:\n",
      "  p-value = 0.007950\n",
      "  All groups were sampled from populations with NOT IDENTICAL variances.\n",
      "\n",
      "Mann-Whitney p-value: 0.4198924460961879 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'no_food': 0.4198924460961879}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_pvalues = {}\n",
    "\n",
    "control = ratio_bouts_df.query('condition==\"food\"')['ratio_bouts']\n",
    "\n",
    "for condition in condition_order[1:]:\n",
    "\n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        test = ratio_bouts_df.query('condition==\"' + condition + '\"')['ratio_bouts']\n",
    "\n",
    "        temp_values = {'control': control, 'test': test}\n",
    "\n",
    "        pvalue_condition = helpers.run_statistics(temp_values)\n",
    "\n",
    "        ratio_bouts_pvalues[condition] = pvalue_condition\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "    \n",
    "ratio_bouts_pvalues"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Effect Size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "no_food\n",
      "Vestigial Effect: 0.0 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'no_food': 0.0}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_effect_sizes = {}\n",
    "\n",
    "control = ratio_bouts_df.query('condition==\"food\"')['ratio_bouts']\n",
    "\n",
    "for condition in condition_order[1:]:\n",
    "    \n",
    "    print(condition)\n",
    "    \n",
    "    test = ratio_bouts_df.query('condition==\"' + condition +'\"')['ratio_bouts']\n",
    "\n",
    "    median_diff = helpers.get_effect_size(control, test, method='median_diff')\n",
    "\n",
    "    ratio_bouts_effect_sizes[condition] = median_diff\n",
    "    \n",
    "ratio_bouts_effect_sizes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALgAAAEgCAYAAAAHcbldAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3dd3RU1fr/8fdkJj0hvfdAEiCFUAKhd1BEQJp8QQxeQcV27djBevWq9yoqFriA/GgKSkdpYugloZdgIL33nkkymfP7IzA6kpAEM5lhsl9rZS2yyWSec/LJyZ5z9jxHJkmShCAYKRN9FyAIuiQCLhg1EXDBqImAC0ZNBFwwaiLgglFrl4B/8cUXhIaGEhYWxsSJE8nLy2uPpxUEZLo+Dx4fH8+UKVM4e/YsdnZ2vPDCC5SXl/PNN9/o8mkFAWiHI3jv3r1JTEzEzs4OpVJJZmYmTk5Oun5aQQDaaYpiamrK5s2b8fb25sCBAzz00EPt8bSC0H4vMidNmkRBQQGLFi1i7NixqNXqm75m0aJFyGQyzYcg/F06n4NfvXq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ZglHr0EdwwfiJgAtGTQRcMGodOuD/+Mc/CAwMZN26dbf9Pe7kdSlNMab90qE7W61cuRKlUmmQTSP1yZj2S4c9gk+Y0HCP+759+/Lhhx82uo5i+/btREZGEhERwaRJkzT9CXfv3k1oaCi9e/dm6dKl+tyMNmd0+0XniwEMGNDkOorc3FzJ09NTSk5OliRJkv79739LU6dOlZRKpeTu7q6548PDDz+sWathLIxpv3TYI/gNTa2jOHHiBH379sXf319r/Pz583h6etKtWzcAYmJi9FW6ThnLfunwAW9qHUVT439dd/LntRnGxFj2S4cPeFPrKPr168exY8dISUkB4Ntvv2X48OFERESQm5vL2bNnAf7WmQZDZiz7xTB+zfToz+so6urq6N27N19//TW2trZ8++233HfffdTW1uLn58f//vc/TE1NWbduHbNnz0ahUNCrVy99b4JOGMt+EWtRBKPW4acognETAReMmgi4YNREwAWjJgIuGDURcMGoiYALRk0EXDBqIuCCURMBF4za/wcg9wGa5gwf3QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 180x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize figure.\n",
    "n_conditions = ratio_bouts_df['condition'].nunique()\n",
    "figure, axis = plt.subplots(figsize=(1.25*n_conditions, 4))\n",
    "\n",
    "# Draw the boxplot.\n",
    "sns.boxplot(x='condition',\n",
    "            y='ratio_bouts',\n",
    "            data=ratio_bouts_df,\n",
    "            order=condition_order,\n",
    "            palette=['steelblue', '#5e6472'],\n",
    "            width=0.6,\n",
    "            showfliers=False,\n",
    "            boxprops={'edgecolor': INK},\n",
    "            medianprops={'color': INK},\n",
    "            whiskerprops={'color': INK},\n",
    "            capprops={'color': INK}\n",
    "           )\n",
    "\n",
    "# Draw the swarmplot.\n",
    "sns.swarmplot(x='condition',\n",
    "              y='ratio_bouts',\n",
    "              data=ratio_bouts_df,\n",
    "              order=condition_order,\n",
    "              palette=['steelblue', '#5e6472'],\n",
    "              linewidth=0.75,\n",
    "              edgecolor=INK\n",
    "             )\n",
    "\n",
    "# Figure and axes formatting.\n",
    "axis.set_xlabel('')\n",
    "axis.set_xticklabels([''])\n",
    "axis.set_ylabel('# Bouts / Minute')\n",
    "axis.set_ylim(0, 3)\n",
    "axis.set_yticks(np.arange(0, 3+0.5, 1))\n",
    "axis.set_yticklabels([int(label) for label in axis.get_yticks()])\n",
    "\n",
    "# Table definition.\n",
    "row1 = [str(ratio_bouts_df.query('condition==\"'+condition+'\"').shape[0]) for condition in condition_order]\n",
    "row2 = ['With\\nfood', 'Without\\nfood']\n",
    "cell_text = np.array([row1, row2])\n",
    "\n",
    "row_labels = ['n =', '']\n",
    "summary_table = axis.table(cellText= cell_text,\n",
    "                           cellLoc='center',\n",
    "                           rowLabels=row_labels,\n",
    "                           rowLoc='center',\n",
    "                           colLoc='center'\n",
    "                          )\n",
    "\n",
    "summary_table.auto_set_font_size(False)\n",
    "summary_table.set_fontsize(11)\n",
    "\n",
    "properties = summary_table.properties()\n",
    "table_cells = properties['children']\n",
    "for cell in table_cells:\n",
    "    cell.set_height(0.12)\n",
    "    cell.set_alpha(0)\n",
    "\n",
    "# Draw statistical result.\n",
    "for p, condition in enumerate(condition_order[1:]):\n",
    "    sig_height = 6 if (ratio_bouts_pvalues.get(condition, 'NaN') == 'NaN') or (ratio_bouts_pvalues.get(condition, 'NaN') >= 0.05) else 2\n",
    "    helpers.plot_stattest_result(ax=axis,\n",
    "                                 x1=p+1,\n",
    "                                 x2=p+1,\n",
    "                                 p_value=ratio_bouts_pvalues.get(condition, 'NaN'),\n",
    "                                 y=2.8,\n",
    "                                 ticksize=0,\n",
    "                                 xytext=(0,sig_height),\n",
    "                                 fontsize=13,\n",
    "                                 color=INK,\n",
    "                                 connector_color=INK\n",
    "                                )\n",
    "\n",
    "# Saving parameters.\n",
    "filename = 'nbouts_aggression_normalized_5mins'\n",
    "plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
